package intefaceGrafica;


import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.List;


public class Acme extends JFrame {

	private JPanel contentPane;
	private JTextField txtLer;
	private JButton btnAddTexto;
	private JMenuItem mntmSair;
	private List lstTexto;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Acme frame = new Acme();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Acme() {
		setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		setBounds(100, 100, 567, 345);
		
		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		
		JMenu mnFile = new JMenu("File");
		menuBar.add(mnFile);
		
		mntmSair = new JMenuItem("Sair");
		mntmSair.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				
			}
		});
		mnFile.add(mntmSair);
		
		JMenu mnNewMenu_1 = new JMenu("Cadastro");
		menuBar.add(mnNewMenu_1);
		
		JMenu mnNewMenu_2 = new JMenu("New menu");
		mnNewMenu_1.add(mnNewMenu_2);
		
		JMenuItem mntmNewMenuItem_1 = new JMenuItem("New menu item");
		mnNewMenu_2.add(mntmNewMenuItem_1);
		
		JMenuItem mntmNewMenuItem_2 = new JMenuItem("New menu item");
		mnNewMenu_1.add(mntmNewMenuItem_2);
		
		JMenuItem mntmNewMenuItem_3 = new JMenuItem("New menu item");
		mnNewMenu_1.add(mntmNewMenuItem_3);
		
		JMenu mnCliente = new JMenu("Cliente");
		menuBar.add(mnCliente);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		txtLer = new JTextField();
		txtLer.setBounds(10, 10, 279, 90);
		contentPane.add(txtLer);
		txtLer.setColumns(10);
		
		btnAddTexto = new JButton("Adicionar Texto");
		btnAddTexto.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			lstTexto.add(txtLer.getText());
			}
		});
		btnAddTexto.setBounds(10, 111, 279, 23);
		contentPane.add(btnAddTexto);
		
		lstTexto = new List();
		lstTexto.setBounds(326, 10, 223, 250);
		contentPane.add(lstTexto);
		
		JButton btnRemove = new JButton("Remover texto");
		btnRemove.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
				lstTexto.remove(txtLer.getText());
						
				
			}
		});
		btnRemove.setBounds(10, 145, 279, 23);
		contentPane.add(btnRemove);
		
		JButton btnLimpaLista = new JButton("Limpa index");
		btnLimpaLista.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				lstTexto.remove(lstTexto.getSelectedIndex());
			}
		});
		btnLimpaLista.setBounds(10, 179, 279, 23);
		contentPane.add(btnLimpaLista);
	}
}
